Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-notion-contents

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-notion-contents

Get contents from notion

  • 2.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
increased by216.67%
Maintainers
1
Weekly downloads
 
Created
Source

get-notion-contents

Get contents from notion

NPM Build Status npm bundle size (minified)

Installation

$ npm i -S get-notion-contents

⚠️ Prerequisite

You need a token to use this package if you want to get private contents. You can get it from Notion.so cookie. the key of it is token_v2.

Development

$ export NOTION_TOKEN="<<YOUR_NOTION_TOKEN>>"
$ npm start

Return type of methods

getUser()
Promise<{
  email: string;
  family_name: string;
  given_name: string;
  id: string;
  onboarding_completed: boolean;
  profile_photo: string;
  version: number;
}>
getPageIds(skipChildren: boolean = false)
Promise<string[]>
getPageById(id: string)
Promise<{
  id: string;
  title: string;
  titleString: string;
  content: string;
  resource?: string;
}>
getPages()
Promise<Array<{
  id: string;
  title: string;
  titleString: string;
  content: string;
  resource?: string;
}>>

How to use

import Notion from 'get-notion-contents';

// create instance of Notion.
const notion = new Notion('<<YOUR_NOTION_TOKEN>>', { prefix: '<<PREFIX_OF_LINK>>', removeStyle: false });

(async () => {
  // get user information
  const user = await notion.getUser();
  console.log(user);

  // get ids of all pages
  const pageIds = await notion.getPageIds();
  console.log(pageIds);

  // get content of a page
  const page = await notion.getPageById(pageIds[0]);
  console.log(page);

  // get contents of all pages
  const pages = await notion.getPages();
  console.log(pages);
})();
Option
  • prefix: add prefix into relative links
  • removeStyle: remove inline styles

Buy Me A Coffee

Keywords

FAQs

Package last updated on 07 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc